package com.smart.member.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.smart.member.entity.Member;

public interface MemberMapper extends BaseMapper<Member> {

    default Member selectByPhone(String phone) {
        QueryWrapper<Member> qw = new QueryWrapper<>();
        qw.lambda().eq(Member::getPhone, phone).eq(Member::getStatus, 1);
        return this.selectOne(qw);
    }

    default Member selectByEmail(String email) {
        QueryWrapper<Member> qw = new QueryWrapper<>();
        qw.lambda().eq(Member::getEmail, email).eq(Member::getStatus, 1);
        return this.selectOne(qw);
    }

    default Member selectByUserName(String username) {
        QueryWrapper<Member> qw = new QueryWrapper<>();
        qw.lambda().eq(Member::getUsername, username).eq(Member::getStatus, 1);
        return this.selectOne(qw);
    }
}